from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
import unittest
import os
from ui_auto.config .config import *
from ui_auto.public.utils.read_ini import Read_ini
from ui_auto.public.pages.basepage import BasePage
from ui_auto.data.page_elem import Analysysdata_elem
from time import strftime
from ui_auto.public.utils.HTMLTestRunner3_New import HTMLTestRunner
from selenium.webdriver.support.wait import WebDriverWait

file=os.path.join(data_path,"data.ini")
r=Read_ini(file)
url=r.read_ini_data("test_analysysdata","url")
username=r.read_ini_data("test_analysysdata","username")
password=r.read_ini_data("test_analysysdata","password")
class Bbs_login(BasePage):
    @classmethod
    def setUpClass(cls) -> None:
        driver=webdriver.Chrome()
        BasePage.set_driver(driver)
        BasePage.max()
    @classmethod
    def tearDownClass(cls) -> None:
        sleep(2)
    def test_bbslogin(self):
        a=BasePage.get_driver()
        a.get(url)
        elem1=BasePage.search_elem(['XPATH',Analysysdata_elem.login_btn])
        BasePage.click(elem1)
        WebDriverWait(a, 3).until(lambda _: a.find_element(By.XPATH,Analysysdata_elem.login_text))
        elem2=BasePage.search_elem(['XPATH',Analysysdata_elem.account_num_inptu])
        BasePage.sendkeys(elem2,username)
        elem3=BasePage.search_elem(['XPATH',Analysysdata_elem.password_input])
        BasePage.sendkeys(elem3,password)
        elem4=BasePage.search_elem(['XPATH',Analysysdata_elem.uba_login_btn])
        BasePage.click(elem4)
        WebDriverWait(a, 3).until(lambda _: a.find_element(By.XPATH,Analysysdata_elem.policy_center_text))
        elem5 = BasePage.search_elem(['XPATH', Analysysdata_elem.setting_btn])
        BasePage.click(elem5)
        elem6 = BasePage.search_elem(['XPATH', Analysysdata_elem.role_members_btn])
        BasePage.click(elem6)
        try:
            elem4=BasePage.search_elem(Bbselem_Iput.bbs_quit)
            value=BasePage.text(elem4)
            self.assertEqual(value,"退出")
        except Exception as e:
            print(e)

if __name__ == '__main__':
    unittest.main()


























































